#ifndef FOCMOTOR_H
#define FOCMOTOR_H


// monitoring bitmap
#define _MON_TARGET 0b1000000 // monitor target value
#define _MON_VOLT_Q 0b0100000 // monitor voltage q value
#define _MON_VOLT_D 0b0010000 // monitor voltage d value
#define _MON_CURR_Q 0b0001000 // monitor current q value - if measured
#define _MON_CURR_D 0b0000100 // monitor current d value - if measured
#define _MON_VEL    0b0000010 // monitor velocity value
#define _MON_ANGLE  0b0000001 // monitor angle value

/**
 *  Motiron control type
 */
typedef enum {
  MotionControl_torque            = 0x00,     //!< Torque control
  MotionControl_velocity          = 0x01,     //!< Velocity motion control
  MotionControl_angle             = 0x02,     //!< Position/angle motion control
  MotionControl_velocity_openloop = 0x03,
  MotionControl_angle_openloop    = 0x04
} MotionControlType;

/**
 *  Motiron control type
 */
typedef enum  { 
  TorqueControl_voltage            = 0x00,     //!< Torque control using voltage
  TorqueControl_dc_current         = 0x01,     //!< Torque control using DC current (one current magnitude)
  TorqueControl_foc_current        = 0x02,     //!< torque control using dq currents
}TorqueControlType;

/**
 *  FOC modulation type
 */
typedef enum {
  FOCModulation_SinePWM            = 0x00,     //!< Sinusoidal PWM modulation
  FOCModulation_SpaceVectorPWM     = 0x01,     //!< Space vector modulation method
  FOCModulation_Trapezoid_120      = 0x02,     
  FOCModulation_Trapezoid_150      = 0x03,     
}FOCModulationType;

typedef enum {
  motor_uninitialized = 0x00,     //!< Motor is not yet initialized
  motor_initializing  = 0x01,     //!< Motor intiialization is in progress
  motor_uncalibrated  = 0x02,     //!< Motor is initialized, but not calibrated (open loop possible)
  motor_calibrating   = 0x03,     //!< Motor calibration in progress
  motor_ready         = 0x04,     //!< Motor is initialized and calibrated (closed loop possible)
  motor_error         = 0x08,     //!< Motor is in error state (recoverable, e.g. overcurrent protection active)
  motor_calib_failed  = 0x0E,     //!< Motor calibration failed (possibly recoverable)
  motor_init_failed   = 0x0F,     //!< Motor initialization failed (not recoverable)
}FOCMotorStatus;
#endif
